﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Athena后台登录</title>
    <link href="~/Content/css/font-awesome.min.css" rel="stylesheet" />
    <link href="~/Content/css/framework-login.css" rel="stylesheet" />
    <script src="~/Content/js/jquery/jquery-1.11.1.js"></script>
    <script src="~/Content/js/cookie/jquery.cookie.js"></script>
    <script src="~/Content/js/md5/jquery.md5.js"></script>
    <script src="~/Content/js/ace.js"></script>
</head>
<body>
    <div class="wrapper" >
        <div class="container">
            <div class="logo">
                <i class="fa fa-modx"></i>
                <h1><span>Athena</span>后台登录</h1>
            </div>
            <form class="form" >
                <div class="row">
                    <input id="txt_account" type="text" value="Athena" placeholder="用户名/手机号/邮箱">
                    <i class="fa fa-user"></i>
                </div>
                <div class="row">
                    <input id="txt_password" type="password" value="123456" placeholder="登录密码">
                    <i class="fa fa-key"></i>
                </div>
                <div class="row">
                    <input id="txt_code" maxlength="4" type="text" placeholder="验证码" style="width: 190px; float: left;">
                    <div style="width: 110px; float: right; padding-top: 14px; padding-left: 14px;">
                        <img id="imgcode" class="authcode" src="~/Login/GetAuthCode" width="80" float: left; />
                        <input id="switchCode" type="button" value="刷新验证码" class="ver_btn" style="width: 190px; float: left;"/>
                    </div>
                </div>
                <div class="row">
                    <button id="login_button" class="submit_btn" type="button" ><span>登录</span></button><br /><br />
@*                    <button id="fastlogin_button" type="button" onclick="fastsubmitForm()"><span>快速登录</span></button>*@
                </div>
                <div class="row">
                </div>
            </form>
            <div class="login_tips"></div>
        </div>
    </div>
    <script type="text/javascript">
            //登录验证
            (function ($) {
                $.login = {
                    formMessage: function (msg) {
                        $('.login_tips').find('.tips_msg').remove();
                        $('.login_tips').append('<div class="tips_msg"><i class="fa fa-question-circle"></i>' + msg + '</div>');
                    },
                    loginClick: function () {

                        var $username = $("#txt_account");
                        var $password = $("#txt_password");
                        var $code = $("#txt_code");
                        if ($username.val() == "") {
                            $username.focus();
                            $.login.formMessage('请输入用户名/手机号/邮箱。');
                            return false;
                        } else if ($password.val() == "") {
                            $password.focus();
                            $.login.formMessage('请输入登录密码。');
                            return false;
                        }
                        else if ($code.val() == "") {
                            $code.focus();
                            $.login.formMessage('请输入验证码。');
                            return false;
                        }
                        else {
                            $("#login_button").attr('disabled', 'disabled').find('span').html("loading...");
                            $.ajax({
                                url: "/Login/CheckLogin",
                                //data: { username: $.trim($username.val()), password: $.trim($password.val()) },
                                data: { username: $.trim($username.val()), password: $.trim($password.val()), code: $.trim($code.val()) },
                            type: "post",
                            dataType: "json",
                            success: function (data) {
                                if (data.success == "true") {
                                    $("#login_button").find('span').html("登录成功，正在跳转...");
                                    window.setTimeout(function () {
                                         window.location.href = "/Home/Index";
                                    }, 500);
                                } else {
                                    $("#login_button").removeAttr('disabled').find('span').html("登录");
                                    $("#switchCode").trigger("click");
                                    $code.val('');
                                    $.login.formMessage(data.Msg);
                                }
                            }
                        });
                    }
                },
                init: function () {
                    $('.wrapper').height($(window).height());
                    $(".container").css("margin-top", ($(window).height() - $(".container").height()) / 2 - 50);
                    $(window).resize(function (e) {
                        $('.wrapper').height($(window).height());
                        $(".container").css("margin-top", ($(window).height() - $(".container").height()) / 2 - 50);
                    });
                    $("#switchCode").click(function () {
                        $("#imgcode").attr("src", "@this.Url.Content("~/Login/GetAuthCode?time=")" + Math.random());
                    });
                   
                    $("#txt_account").focus();
                    $("#login_button").click(function () {
                        $.login.loginClick();
                    });
                    document.onkeydown = function (e) {
                        if (!e) e = window.event;
                        if ((e.keyCode || e.which) == 13) {
                            document.getElementById("login_button").focus();
                            document.getElementById("login_button").click();
                        }
                    }
                }
            };
            $(function () {
                $.login.init();
            });
        })(jQuery);
    </script>
</body>
</html>